package cn.texous.demo.dkc.kafka2aws.context;

import org.apache.kafka.common.TopicPartition;
import org.apache.kafka.connect.sink.SinkTaskContext;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * sink task context
 *
 * @author leven
 * @since
 */
public class MySinkTaskContext implements SinkTaskContext {
    private final Map<TopicPartition, Long> offsets = new HashMap();
    private long timeoutMs = -1L;
    private Set<TopicPartition> assignment;

    public MySinkTaskContext(Set<TopicPartition> assignment) {
        this.assignment = assignment;
    }

    public Map<String, String> configs() {
        throw new UnsupportedOperationException();
    }

    public void offset(Map<TopicPartition, Long> offsets) {
        this.offsets.putAll(offsets);
    }

    public void offset(TopicPartition tp, long offset) {
        this.offsets.put(tp, offset);
    }

    public Map<TopicPartition, Long> offsets() {
        return this.offsets;
    }

    public void timeout(long timeoutMs) {
        this.timeoutMs = timeoutMs;
    }

    public long timeout() {
        return this.timeoutMs;
    }

    public Set<TopicPartition> assignment() {
        return this.assignment;
    }

    public void setAssignment(Set<TopicPartition> nextAssignment) {
        this.assignment = nextAssignment;
    }

    public void pause(TopicPartition... partitions) {
    }

    public void resume(TopicPartition... partitions) {
    }

    public void requestCommit() {
    }
}
